package com.elinkway.infinitemovies.async;

import android.content.Context;

import com.elinkway.infinitemovies.bean.MainHeaderList;
import com.elinkway.infinitemovies.http.api.MoviesHttpApi;
import com.elinkway.infinitemovies.http.parser.MainHeaderListParser;
import com.lvideo.http.bean.LVideoDataHull;

public class RequestMainHeaderTask extends MoviesHttpAsyncTask<MainHeaderList>{

	public RequestMainHeaderTask(Context context) {
		super(context);
	}

	@Override
	public LVideoDataHull<MainHeaderList> doInBackground() {
		return MoviesHttpApi.mainHeaderRequst(new MainHeaderListParser());
	}
	private RequestResultListener <MainHeaderList> mListener;

	@Override
	public void onPostExecute(int updateId, MainHeaderList result) {
		if(null != mListener) {
			mListener.onRequestSuccess(updateId, result);
		}
	}

	public RequestResultListener <MainHeaderList> getListener() {
		return mListener;
	}

	@Override
	public void netNull() {
		super.netNull();
		if(null != mListener) {
			mListener.onRequestFailed();
		}
	}

	@Override
	public void netErr(int updateId, String errMsg) {
		super.netErr(updateId, errMsg);
		if(null != mListener) {
			mListener.onRequestFailed();
		}
	}

	@Override
	public void dataNull(int updateId, String errMsg) {
		super.dataNull(updateId, errMsg);
		if(null != mListener) {
			mListener.onRequestFailed();
		}
	}

	public void setListener(RequestResultListener <MainHeaderList> mListener) {
		this.mListener = mListener;
	}

}
